//
//  YFLCollectionViewCell.m
//  Music
//
//  Created by dllo on 16/6/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YFLCollectionViewCell.h"
#import "NianFeilongModel.h"
#import "YFLlittleTableViewCell.h"
#import "YFLmvTableViewCell.h"
#import "YFLmvModel.h"
#import "YFLmvStartViewController.h"

@implementation YFLCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame

{
    
    self = [super initWithFrame:frame];
    if (self) {
        self.naVC =[[UINavigationController alloc]init];
        self.dataArray =[NSMutableArray array];
        self.sourceArray = [NSMutableArray array];
       // self.mvDIC =[NSDictionary dictionary];
        self.MVstart =[NSMutableArray array];
        
        
        self.tableView =[[UITableView alloc]initWithFrame:CGRectMake(0, 5, Screenwidth,  Screenheight-64-49-(Screenheight/2-64)-25) style:(UITableViewStylePlain)];
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
        
        [self.contentView addSubview:self.tableView];
        
        
        
    [self.tableView registerClass:[YFLlittleTableViewCell class] forCellReuseIdentifier:@"cell"];
        
        [self.tableView registerClass:[YFLmvTableViewCell class] forCellReuseIdentifier:@"MVcell"];
        
        
        
    }
    return self;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.indexBottom == 0) {
        return self.dataArray.count;
    }if (self.indexBottom == 2) {
        return self.sourceArray.count;
    }
    return 10;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  //  NSLog(@"2222222222222222222222+++++++++++++%ld",self.indexBottom);
    
    if (self.indexBottom == 0) {
       // NSLog(@"///////////////////////////////////%ld",self.indexBottom);
        NianFeilongModel *model =[self.dataArray objectAtIndex:indexPath.row];
        YFLlittleTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"];
        
        
        cell.DataModel = model;
     
        return cell;

    } if  (self.indexBottom == 2) {
       // NSLog(@"====================================%ld",self.indexBottom);
        YFLmvModel *model1 =[self.sourceArray objectAtIndex:indexPath.row];
        YFLmvTableViewCell *cell =[self.tableView dequeueReusableCellWithIdentifier:@"MVcell"];
        cell.mvModel = model1;
    
        return cell;
        
        
        
        
    }
 //   NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%ld",self.indexBottom);
    return nil;
             }

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}

//进行跳转
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.indexBottom == 0) {
        NSLog(@"跳转到单曲播放界面");
    }if (self.indexBottom == 2) {
        NSLog(@"跳转进MV界面");
        
        
        YFLmvStartViewController *mvVC =[[YFLmvStartViewController alloc]init];
      //  NSLog(@"=================888877777777778888===========%@",self.MVstart);
        
        NSDictionary *dic =[self.MVstart objectAtIndex:indexPath.row];
        
        mvVC.urlString =[dic objectForKey:@"url"];
        
    //    NSLog(@"--------------------------/888888888888888888-*----------%@",mvVC.urlString);
     //   [self.naVC pushViewController:mvVC animated:YES];
        [self.naVC presentViewController:mvVC animated:YES completion:nil];
        
        
        
        
    }
}


-(void)setDataArray:(NSMutableArray *)dataArray
{
    if (_dataArray != dataArray) {
        _dataArray = dataArray;
        
    }
    [self.tableView reloadData];
}
-(void)setSourceArray:(NSMutableArray *)sourceArray
{
    if (_sourceArray != sourceArray) {
        _sourceArray = sourceArray;
    }
    [self.tableView reloadData];
}
@end
